package com.ucomm.talent.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.ucomm.talent.R;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Vita Hao
 * Date: 13-5-24
 * Time: 下午2:59
 * To change this template use File | Settings | File Templates.
 */
public class CustomListAdapter extends BaseAdapter{

    private LayoutInflater mInflater;
    private List<Map<String, Object>> mData;

    public CustomListAdapter(Context context ,  List<Map<String, Object>> mData){
        this.mInflater = LayoutInflater.from(context);
        this.mData = mData;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int arg0) {
        return mData.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            holder=new ViewHolder();

            convertView = mInflater.inflate(R.layout.custom_list_item, null);
//            holder.img = (ImageView)convertView.findViewById(R.id.img);
//            holder.title = (TextView)convertView.findViewById(R.id.title);
//            holder.info = (TextView)convertView.findViewById(R.id.info);
//            holder.viewBtn = (Button)convertView.findViewById(R.id.view_btn);
            convertView.setTag(holder);

        }else {

            holder = (ViewHolder)convertView.getTag();
        }


//        holder.img.setBackgroundResource((Integer)mData.get(position).get("img"));
//        holder.title.setText((String)mData.get(position).get("title"));
//        holder.info.setText((String)mData.get(position).get("info"));

//        holder.viewBtn.setOnClickListener(new View.OnClickListener() {
//
//            @Override
//            public void onClick(View v) {
//            }
//        });


        return convertView;
    }

    final class ViewHolder{
        public ImageView img;
        public TextView title;
        public TextView info;
        public Button viewBtn;
    }
}
